<?php
namespace app\common\model\Cart;

use app\common\model\Goods\GoodsCommonModel;
use app\common\model\Goods\GoodsSpecCommonModel;
use support\Model;
use think\model\concern\SoftDelete;
use think\model\relation\BelongsTo;


/**
 * 购物车的公共模型
 * Class CartCommonModel
 * @package app\common\model\Cart
 */
class CartCommonModel extends Model
{
    use SoftDelete;

    protected $name = "cart";

    protected $pk = "id";

    protected $deleteTime = 'deletetime';


    /**
     * 是否为秒杀商品
     */
    CONST IS_KILL_FALSE = 0;
    CONST IS_KILL_TRUE = 1;


    /**
     * 关联商品规格
     * @return \think\model\relation\BelongsTo
     */
    public function belongsToGoodsSpec()
    {
        return $this->belongsTo(GoodsSpecCommonModel::class , 'spec_id' , 'id');
    }

    /**
     * 关联商品
     * @return BelongsTo
     */
    public function belongsToGoods()
    {
        return $this->belongsTo(GoodsCommonModel::class , 'goods_id' , 'id');
    }

}